<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %><%--
常用的JSTl标签
1. if       相当于Java的if语句
2. choose   相当于Java的switch语句
3. foreach  相当于Java的for语句
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>JSTL简化和替换jsp页面的java代码</title>
</head>
<body>
<%--
c:if标签
    1.属性
        test必须属性。接受Boolean表达式 如果为true则显示
        c:if标签没有else
--%>
<c:if test="true">
    真
</c:if>

<% request.setAttribute("number",3); %>
<c:choose>
    <c:when test="${number} == 1">星期一</c:when>
    <c:when test="${number} == 2">星期二</c:when>
    <c:when test="${number} == 3">星期三</c:when>
    <c:when test="${number} == 4">星期四</c:when>
    <c:when test="${number} == 5">星期五</c:when>
    <c:when test="${number} == 6">星期六</c:when>
    <c:when test="${number} == 7">星期日</c:when>
    <c:otherwise>数字输入有误</c:otherwise>
</c:choose>
<%--
c:foreach标签
begin 开始值  end结束值  var 临时变量 step 步长 varStatus 循环状态对象（index容器中元素的索引0 count循环次数1）
--%>
<c:forEach begin="1" end="10" var="i" step="1" >
    ${i}<br>
</c:forEach>

<%
    List list = new ArrayList();
    list.add("aaa");list.add("bbb");list.add("ccc");
    request.setAttribute("list",list);
%>
<c:forEach items="${list}" var="str" varStatus="s">
    ${s.index} ${s.count} ${str}<br>
</c:forEach>
</body>
</html>
